﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.ComponentModel.Composition;

namespace MEF_Hello_World.Test
{
    [TestClass]
    public class MEF_Hello_World
    {
        [TestMethod]
        public void MEF_Hello_World_TestMethod()
        {
            var catalog = new AttributedTypesPartCatalog(typeof(Foo), typeof(BarWithSingleFoo));
            var container = new CompositionContainer(catalog.CreateResolver());

            var bar = new BarWithSingleFoo();
            var foo = new Foo();

            container.AddPart(bar);
            container.AddPart(foo);

            container.Compose();

            Assert.IsNotNull(bar.Foo);
            Assert.AreSame(foo, bar.Foo);
            
            Console.Write("Hello World! No Error Found!");

        }
    }
}
